/**
* @author Jerry
*/

import * as React from "react";
import { Component, PropTypes } from "react";
import { filter, fetch } from "../../renderer";
import * as cx from "classnames";
import { Enhance as FormItem } from "../form-item";
import {
    InputGroup,
    FormControl,
    Button
} from 'react-bootstrap';

import * as Rate  from "rc-rate";
import '../../../static/less/star.less';

@FormItem({
  type: "star-rate"
})
export default class FormStarRate extends Component {
    static propTypes = {
        className: PropTypes.string,
        formMode: PropTypes.string,
        formHorizontal: PropTypes.object,
        inputClassName: PropTypes.string
    };

    static defaultProps = {
        value: 0,
    };

    constructor(props) {
        super(props);

        this.handleChange = this.handleChange.bind(this);
        // this.handleHoverChange = this.handleHoverChange.bind(this);



        this.state = {

        };
    }


    handleChange(value) {
        const {
            setValue
        } = this.props;

        setValue(value);
    }

    // handleHoverChange(value) {
    //     const {
    //         setValue
    //     } = this.props;
    //
    //     setValue(value);
    // }

    render() {
        let {value, data, disabled, inputClassName, width, height, style, count} = this.props;

        style = style || {};

        width && (style.width = width);
        height && (style.height = height);
        console.info(Rate);
        // return null;
        return (
            <Rate
                value={value || 0}
                onChange={this.handleChange}
                onHoverChange={this.handleHoverChange}
                count={count || 5}
                // disabled={disabled}
            />);
    }
}
